package cn.lycode.common.utils.file;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * FileUploadUtils
 */
public class FileUploadUtils {

    /**
     * 生成文件名
     *
     * @param originalFilename 原始文件名
     * @return {@link String}
     */
    public static String generateFileName(String originalFilename) {
        //按时间(月)分文件夹
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        String localTime = sdf.format(new Date());
        String pathStr = "/" + localTime + "/";

        String fileName = UUID.randomUUID().toString();
        return pathStr+ fileName + originalFilename;
    }
}